package com.example.demo1;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class RequestAPI extends HttpServlet{
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //getRequestURI()		获取请求的资源路径
        System.out.println("URI->"+req.getRequestURI());
        //(2)getRequestURL()			  获取请求的统一资源定位符
        System.out.println("URL->"+req.getRequestURL());
        //(3)getRemoteHost()		获取客户端的ip地址
        System.out.println("客户端的ip地址"+req.getRemoteHost());
        //(4)getHeader()				获取请求头
        System.out.println("请求头User-Agent"+req.getHeader("User-Agent"));
        //getParameter()			获取请求的参数

        //(6)getParameterValues()	获取请求的参数（多个值的时候使用)

        //(7)getMethod()				获取请求的方式GET或POST

        //(8)setAttribute(key,value)	设置域数据



        //(10)getRequestDispatcher()	获取请求转发对象


    }
}
